package com.yu.demo;

import java.util.concurrent.*;

public class Demo {
    /*public static void main(String[] args) {
        ExecutorService es = new ThreadPoolExecutor(int corePoolSize,
        int maximumPoolSize,
        long keepAliveTime,
        TimeUnit unit,
        BlockingQueue<Runnable> workQueue,
        ThreadFactory threadFactory,
        RejectedExecutionHandler handler);

    }*/

   /* public static void main(String[] args) {
        ScheduledExecutorService  ThreadPool = Executors.newScheduledThreadPool(10);
        for(int i=0;i<60;i++){
            ThreadPool.scheduleAtFixedRate(new TestThread(i),1,1000,TimeUnit.MILLISECONDS);
        }
    }*/


    public static void main(String[] args) {
        ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 1, 0, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(1));
        pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
        for (int i = 0; i < 10; i++) {
            Runnable myrun = new TestThread(i);
            pool.execute(myrun);
        }
        pool.shutdown();
    }


}
